package com.ocelot.san.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.ocelot.san.dto.Concept;
import com.ocelot.san.repository.ConceptRepository;
import com.ocelot.san.type.SegmentType;

@Service
public class ConceptService {
	
	@Resource
	private ConceptRepository conceptRepository;
	
	public void save(Concept description) {
		conceptRepository.save(description);
	}
	
	public Concept findById(Long id) {
		return conceptRepository.findOne(id);
	}

	public void delete(Long id) {
		conceptRepository.delete(id);
	}

	public void deleteAll() {
		conceptRepository.deleteAll();
	}

	public List<Concept> fetchAll() {
		return conceptRepository.findAll(new Sort(Sort.Direction.ASC, "name"));
	}

	public List<Concept> fetchBySegmentType(SegmentType segmentType) {
		return conceptRepository.findBySegmentType(segmentType);
	}
}
